﻿using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Linq;
using System.Web.Mvc;
using InfoTech.Core.Service;
using InfoTech.LanTranh.MucVu.Bussiness;

namespace InfoTech.LanTranh.MucVu.Service
{
    public class QUANHEGIATOCService : BaseService
    {
        public static bool Check_Insert_QUANHEGIATOC(QUANHEGIATOC quanhegiatoc)
        {
            return true;
        }

        public static bool Check_Update_QUANHEGIATOC(QUANHEGIATOC quanhegiatoc)
        {
            return true;
        }

        public static bool Check_Delete_QUANHEGIATOC(string[] strings)
        {
            bool result = true;
            DataContext dataContext = CreateDataContext();
            result &= dataContext.GetTable<GIAODAN_QUANHEGIATOC>().FirstOrDefault(c => strings.Contains(c.MAGIATOC + "")) == null;
            result &= dataContext.GetTable<HOGIADINH_GIAODAN>().FirstOrDefault(c => strings.Contains(c.MAQUANHEGIATOC + "")) == null;
            return result;
        }

        public static IEnumerable<SelectListItem> Get_List()
        {
            List<SelectListItem> list = new List<SelectListItem>();
            list.Add(new SelectListItem() { Text = "--- {Chọn Quan Hệ} ---", Value = "" });
            DataContext dataContext = CreateDataContext();
            list.AddRange(dataContext.GetTable<QUANHEGIATOC>().OrderBy(c => c.TENQUANHEGIATOC).Select(c => new SelectListItem() { Text = c.TENQUANHEGIATOC, Value = c.MAQUANHEGIATOC + "" }));
            return list;
        }
    }
}
